<include file="Public:wapheader" />
		<div class="page10">
			
			<div class="mainner">
				<div class="title">
					<ul>
						<li class="on">物业地址</li>
						<li>基本信息</li>
						<li>完成</li>
					</ul>
				</div>
				
				<div class="cont">
					<form name="form-phone" action="{:U('used/add')}" method="post" id="form-phone">
					<div class="table1">
						<h4>选择委托类型</h4>
						<ul>
							<li><input type="radio" name="sell_type" id="type1" value="1" checked="checked" /> <label for="type1" >出售</label></li>
							<li><input type="radio" name="sell_type" id="type2" value="2"/> <label for="type2" >出租</label></li>
							<li><input type="radio" name="sell_type" id="type3" value="3"/> <label for="type3" >租售</label></li>
						</ul>
					</div>
					<div class="table2">
						<h4>填写物业地址</h4>
						<ul>
							<li>
								<p>楼盘</p>
								<span>
									<input type="text"  name="title" id="autocomplete"  placeholder="输入小区名" class="required">
									<input type="hidden"  name="area_id" id="area_id" >
									<input type="hidden"  name="estate_id" id="estate_id" >
									<input type="hidden"  name="estate" id="estate" >
								</span>
							</li>
							<li>
								<p>楼栋</p>
								<select name="build" id="build" validate="required:true" min="1">
									<option value="0">请选择</option>
								</select>
							</li>
							<li id="s-unit">
								<p>单元</p>
								<select name="unit" id="unit" validate="required:true" min="1">
									<option value="0">请选择</option>
								</select>
							</li>
							<li>
								<p>门牌</p>
								<select name="room" id="room" validate="required:true" min="1">
									<option value="0">请选择</option>
								</select>
							</li>
							<li>
								<p>地址</p>
								<input type="text" name="address" placeholder="请输入详细地址" />
							</li>
						</ul>
					</div>
					<div class="btn_submit">
						<input type="submit" value="下一步" class="next-btn">
					</div>
					</form>
				</div>
			</div>
			
		</div>
	</body>
<script src="__S__/js/ajaxfileupload.js"></script>
<script src="__S__/js/jquery.validate.js"></script>
<script src="__S__/js/magess.js"></script>
<script src="__S__/js/jquery.metadata.js"></script>
<script type="text/javascript">
	$().ready(function() {
		$("#form-phone").validate();
		jQuery.validator.addMethod("ismobile", function(value, element) {
			var length = value.length;
			var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
			return this.optional(element) || (length == 11 && mobile.test(value));
		}, "请正确填写您的手机号码");
	});

</script>
<script>
	//自动填充
	$( "#autocomplete" ).autocomplete({
		source: "{:U ('Ajax/autoEstate')}",
		select: function(event, ui){
			$(this).val (ui.item.label);
			$('#area_id').val (ui.item.area_id);
			$('#estate_id').val (ui.item.value);
			$('#estate').val (ui.item.label);
			var html = '';
			$.each (ui.item.build, function (i,v){
				html += '<option value="'+v.bid+'">'+v.alias+'</option>';
			});
			$("#build option:eq(0)").nextAll('option').remove();
			$('#build').append(html);
			event.preventDefault();
		}
	});
	$('#build').change(function (){
		var bid = $(this).val();
		var url = "{:U('ajax/getUnit')}";
		var data = {id:bid};
		$.post (url, data, function (response){
			if (response.state == 'ok'){
				var _data = response.data;
				var html = '';
				if(response.count >1){
					$('#s-unit').show ();
					$('#unit').attr ('validate', 'required:true');
					$.each (_data, function (i,v){
						html += '<option value="'+v.unid+'">'+v.alias+'单元</option>';
					});
					$("#unit option:eq(0)").nextAll('option').remove();
					$('#unit').append(html);
				}else{
					$('#s-unit').hide ();
					$('#unit').attr ('validate', '');
					$("#unit").empty();
					var id = _data[0].unid;
					var url = "{:U('Ajax/getRoom')}";
					var data = {id:id};
					$.post (url, data, function (response){
						if (response.state == 'ok'){
							var html = '';
							var data = response.data;
							$.each (data, function (i,v){
								html += '<option value="'+v.rid+'">&nbsp;&nbsp;&nbsp;&nbsp;'+v.floor+v.alias+'&nbsp;&nbsp;&nbsp;&nbsp;</option>';
							})
							$("#room option:eq(0)").nextAll('option').remove();
							$('#room').append(html);

						}else{
							$("#room option:eq(0)").nextAll('option').remove();
						}
					}, 'json')
				}

			}
		},'json');
	});
	$('#unit').change(function (){
		var unid = $(this).val();
		var url = "{:U('ajax/getRoom')}";
		var data = {id:unid};
		$.post (url, data, function (response){
			if (response.state == 'ok'){
				var _data = response.data;
				var html = '';
				$.each (_data, function (i,v){
					html += '<option value="'+v.rid+'">'+v.floor+v.alias+'</option>';
				});
				$("#room option:eq(0)").nextAll('option').remove();
				$('#room').append(html);
			}
		},'json');
	});
</script>
</html>
